$(function(){
	youtube_play_index.run();	
});

var youtube_play_index = {
	run: function(){
		this._init_();			
		this._start_();
		this._bind_events();
	},
	_init_: function(){
		this.id = $("#id").val() || "";	
		this.title = $("#title").val() || "";
		this.category = $("#category").val() || "";
		this.itemUrl = $("#itemUrl").val();
		this.title = $("#title").val();
		this.vdInstalled = vd.check();
	},
	_start_: function(){
		main._play_close_side();
		main.addOrUpdateViewHistory(this.category, this.title, this.id);
		_gaq.push([ '_trackEvent', 'Featured-youtube', 'play', location.href]);
		
		var path = location.pathname;
		if(path.indexOf("/world/featured/") >= 0){
			this.isI18n = true;
			$("#side_menu > ul > li").eq(0).addClass("curr");
		}
		
		youtube_play_index._get_relate_video();
	},
	
	_bind_events: function(){
		var locaIndex = location.href.indexOf("#"); 
		var localUrl = location.href;
		if(locaIndex > 0){
			localUrl = localUrl.substring(0,locaIndex);
		}
		$("#fb-comments").attr("data-href", localUrl);
		$(".loadingBox").show();
	},
	
	_get_relate_video: function(){		
		var url = main.contextPath + "/featured/youtube/relate/" + this.id;
		if(this.isI18n){
			url = main.contextPath + "/world/featured/youtube/relate/" + this.id;
		}
		
		$.get(url, function(result){
			$("#other_video").html(result.trim());
		});
	}
};